<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <img src="111.jpg" alt="">

    <script>
        let img = document.querySelector('img');
        img.onclick = function() {
            console.dir(img);
            if(img.src.indexOf('111.jpg') >= 0) {
                img.src = '222.jpg';
            } else if (img.src.indexOf('222.jpg' >= 0)) {
                img.src = '111.jpg'
            }
        }
    </script>
</body>
</html>